//
//  SEGMenuListManager.m
//  FrameworkTest
//
//  Created by 刘山 on 2018/4/8.
//  Copyright © 2018年 刘山. All rights reserved.
//

#import "SEGMenuListManager.h"

#if __has_include(<SEGPlatform/SEGPlatformManager.h>)
#import <SEGPlatform/SEGPlatformManager.h>
#else
#import "SEGPlatformManager.h"
#endif
#if __has_include(<Commom/SEGProfileManager.h>)
#import <Commom/SEGProfileManager.h>
#else
#import "SEGProfileManager.h"
#endif
#if __has_include(<Commom/SEGNeighborRollViewModel.h>)
#import <Commom/SEGNeighborRollViewModel.h>
#else
#import "SEGNeighborRollViewModel.h"
#endif
#if __has_include(<Commom/SEGNeighbourhoodTalkViewModel.h>)
#import <Commom/SEGNeighbourhoodTalkViewModel.h>
#else
#import "SEGNeighbourhoodTalkViewModel.h"
#endif

#if __has_include(<Commom/SEGQueryneighborhoodmoreManager.h>)
#import <Commom/SEGQueryneighborhoodmoreManager.h>
#else
#import "SEGQueryneighborhoodmoreManager.h"
#endif

#import "SEGMenuSideslipViewModel.h"
#import "SEGUhomeMediator+SEGStandard.h"
#import "SEGSquareViewModel.h"
#import "SEGPropertyNoticeVerticalRollSingleViewModel.h"
#import "SEGCommunityLocationView.h"

#import "SEGCommunitySocialManager.h"
#import "SEGActivityListManager.h"
#import "SEGQuiztypelistManager.h"
#import "SEGMenulist2Manager.h"
#import "SEGPictoriallistManager.h"
#import "SEGMenuListCacheManager.h"

@interface SEGMenuListRowModel : NSObject
@property (nonatomic, assign) SEGEnumShowType type;
/**
 存放正常数据类型的数据集
 */
@property (nonatomic, strong)NSArray<SEGMenuListModel*> *normalMenu;
/**
 特殊业务菜单
 */
@property (nonatomic, strong)SEGMenuListModel *bussinessMenu;
@end

@implementation SEGMenuListRowModel
@end

@interface SEGMenuListManager()
/** 侧滑推荐位数据源 */
@property (nonatomic, strong) NSArray<SEGSquareViewModel *> *squareData;
/** 邻里头条数据源 */
@property (nonatomic, strong) NSArray<SEGNeighborRollViewModel *> *neighborData;
@property (nonatomic, strong) SEGAdvertisementViewModel* advertisementData;
/** 邻居们都在聊数据模型 */
@property (nonatomic, strong) SEGNeighbourhoodTalkViewModel *neighbourhoodTalkData;
@property (nonatomic, strong) SEGMenuSideslipViewModel *oldPgcData;
@property (nonatomic, strong) NSArray *propertyNoticeData;//滚动物业通知

@property (nonatomic, strong) SEGAdvertisementViewModel* recommendationAdvertisementData;//精品推荐广告数据
@property (nonatomic, strong) SEGCommunitySocialManager *marketManager; ///< 请求跳蚤市场manager
@property (nonatomic, strong) SEGActivityListManager *activityManager;
@property (nonatomic, strong) NSArray<SEGActivityListModel*> *activityModels;

@end

@implementation SEGMenuListManager
/**
 查询菜单数据中是否存在导航栏，存在返回数据模型，不存在返回nil
 
 @param data 原菜单导航栏数据源
 @return 导航栏数据模型
 */
+(SEGMenuListModel*) segGetNavigationBarData:(NSArray<NSArray<SEGMenuListModel *> *> *)data{
    __block SEGMenuListModel *model;
    [data enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
        [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
            if ([objRow.widgetType integerValue] == SEGEnumShowTypeNavigationBar_99001 ||
                [objRow.widgetType integerValue] == SEGEnumShowTypeNavigationBar_99002 ||
                [objRow.widgetType integerValue] == SEGEnumShowTypeNavigationBar_99003 ||
                [objRow.widgetType integerValue] == SEGEnumShowTypeNavigationBar_99004 ||
                [objRow.widgetType integerValue] == SEGEnumShowTypeNavigationBar_99005) {
                model = objRow;
                *stopRow = YES;
                *stopSec = YES;
                return;
            }
        }];
    }];
    return model;
}
#pragma mark - ==============v4.8.0优化版本==============
/**
 实时侧滑推荐位数据
 
 @author Sam
 @version 4.8.0
 */
- (void)segRefreshHotNewsWithParams:(NSDictionary*)params Finished:(hotnewsBlock)finished {
    if (self.menuListDataArr.count <= 0)  return;/*如果没有配置菜单，就没有必要去请求侧滑推荐位的数据了*/
    
    //判断当前菜单配置中是否存在 侧滑推荐位 控件，不存在就不必请求网络。
    __block BOOL hasHotnews = NO;
    [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
        [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
            if(objRow.widgetType.integerValue == SEGEnumShowTypeHotNews) {//侧滑推荐位
                hasHotnews = YES;
                return;
            }
        }];
    }];
    
    if (!hasHotnews){
        finished(hasHotnews);
        return;
    }
    
    __weak typeof(self) weakSelf = self;
    [self requestHotNewsWithParams:params Finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        __strong typeof(weakSelf) strongSelf = weakSelf;
        dispatch_async(dispatch_get_main_queue(), ^{
            if (isSuccessed) strongSelf.squareData = result;
            if (!strongSelf.squareData || strongSelf.squareData.count <= 0) strongSelf.squareData = [SEGMenuListManager segGetHotNews];
            

            
            [strongSelf.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
                [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
                    if(objRow.widgetType.integerValue == SEGEnumShowTypeHotNews) {//侧滑推荐位
                        //model 数据绑定
                        objRow.squareData = strongSelf.squareData;
                        return;
                    }
                }];
            }];
            
            finished(hasHotnews);
            return ;
        });
    }];
}
#pragma mark - ==============v4.7.0优化版本==============
/**
 实时请求邻里头条数据
 
 @author Sam
 @version 4.7.0
 */
- (void)segNeighborToplineFinished:(testBlock)finished {
    if (self.menuListDataArr.count <= 0) return;
    /*如果没有配置菜单，就没有必要去请求邻里头条的数据了*/
    __block BOOL hasTopLine = NO;
    [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
        [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
            if(objRow.widgetType.integerValue == SEGEnumShowTypeTopLine) {// 邻里头条
                hasTopLine = YES;
                return;
            }
        }];
    }];
    if (!hasTopLine) return;
    __weak typeof(self) weakSelf = self;
    [self requestTopLineFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        __strong typeof(weakSelf) strongSelf = weakSelf;
        dispatch_async(dispatch_get_main_queue(), ^{
            if (isSuccessed) strongSelf.neighborData = result;
            if (!strongSelf.neighborData || strongSelf.neighborData.count <= 0) strongSelf.neighborData = [SEGMenuListManager segGetNeighborTopLine];
            __block NSArray<SEGNeighborRollViewModel *> *neighborTopLineData = nil;
            __block BOOL hasTopLine = NO;
            [strongSelf.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
                [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
                    if(objRow.widgetType.integerValue == SEGEnumShowTypeTopLine) { // 邻里头条
                        objRow.neighborTopLineData = strongSelf.neighborData;
                        neighborTopLineData = objRow.neighborTopLineData;
                        hasTopLine = YES;
                        return;
                    }
                }];
            }];
            finished(hasTopLine, NO, NO, neighborTopLineData);
            return ;
        });
    }];
}
#pragma mark - ==============v4.6.0优化版本==============
/**
 * 获取本地菜单数据-邻里头条-测滑推荐位-PGC---> 主线程刷新
 * @author Sam
 * @version 4.6.0
 */
- (void)segAsyncGetLocalDataWithAction:(NSString*)action PositionType:(SEGAdvlistType)type settingsId:(NSString*)settingsId finished:(testBlock)finished {
    
    dispatch_group_t group = dispatch_group_create();
    dispatch_queue_t queue = dispatch_queue_create("com.uhome.menu", DISPATCH_QUEUE_CONCURRENT);
    
    //获取菜单数据
    __block BOOL hasTopLine = NO, hasHotNews = NO, hasNewPGC = NO, hasAD = NO, hasCommonMenu = NO;
    dispatch_barrier_async(queue, ^{
        [self segShowLocalDataWithAction:action settingsId:settingsId];
        
        [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
            [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
                if (objRow.widgetType.integerValue == SEGEnumShowTypeTopLine) hasTopLine = YES;
                if (objRow.widgetType.integerValue == SEGEnumShowTypeHotNews) hasHotNews = YES;
                if (objRow.widgetType.integerValue == SEGEnumShowTypeNewPGC) hasNewPGC = YES;
                if (objRow.widgetType.integerValue == SEGEnumShowTypeFourColumsSpread_common) hasCommonMenu = YES;
                if (objRow.widgetType.integerValue == SEGEnumShowTypeAD) hasAD = YES;
            }];
        }];
    });
    
    //PGC列表本地数据
    dispatch_group_async(group, queue, ^{
        // 读取PGC本地数据来做数据扩展
        if(hasNewPGC)[self.pgcManager segPGCLayoutFromLocal];
    });
    
    //测滑推荐位数据
    dispatch_group_async(group, queue, ^{
        if(hasHotNews) self.squareData = [SEGMenuListManager segGetHotNews];
    });
    
    // 获取邻里头条本地数据
    dispatch_group_async(group, queue, ^{
        if(hasTopLine) self.neighborData = [SEGMenuListManager segGetNeighborTopLine];
    });
    
    // 获取本地广告数据
    dispatch_group_async(group, queue, ^{
        if (hasAD) {
            NSArray *ad = [[SEGAdvlistManager sharedManager] segGetAdvertisementWithPostion:type];
            self.advertisementData = [self segAdvertisementWithData:ad type:type];
        }
    });
    
    
    dispatch_group_notify(group, queue, ^{
        [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
            [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
                if(objRow.widgetType.integerValue == SEGEnumShowTypeAD){
                    SEGEnumAdvertismentType adType = SEGEnumAdvertismentType_NO;
                    if (type == SEGAdvlistType_SERVER) adType = SEGEnumAdvertismentType_Find;
                }
            }];
        }];
        
        // 把数据封装成SEGMenuListModel, 控制row的数量
        self.menuListDataArr = [self menuList_packagingDataToSEGMenuListModelWithAction:action PositionType:type settingsId:settingsId];
        
        dispatch_async(dispatch_get_main_queue(), ^{
            finished(hasTopLine, hasAD, hasCommonMenu, self.neighborData);
        });
    });
}

/**
 * 获取服务器菜单数据->通过菜单数据中控件类型去请求相应的网络数据
 * 请求网络数据：菜单、邻里头条、测滑推荐、邻居们都在聊、广告、PGC
 * @author Sam
 * @version 4.6.0
 */
-(void)segReqqustMenuDataAndBusinessDataWithMenuSid:(NSString*)menuSid
                                             action:(NSString*)action
                                       PositionType:(SEGAdvlistType)type
                                         settingsId:(NSString*)settingsId
                                      hotNewsParams:(NSDictionary*)hotNewsParams
                                           targetVC:(UIViewController*)targetVC
                                           Finished:(testBlock)finished{
    
    //请求菜单数据
    __weak typeof(self) weakSelf = self;
    [self requestMenuListWithMenuSidV2:menuSid settingsId:settingsId action:action finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        __strong typeof(weakSelf) strongSelf = weakSelf;
        dispatch_group_t group = dispatch_group_create();
        dispatch_queue_t queue = dispatch_queue_create("com.uhome.menu.server", DISPATCH_QUEUE_CONCURRENT);
        
        __block BOOL hasTopLine = NO, hasHotNews = NO, hasNewPGC = NO, hasAD = NO, hasNeighborTalk = NO, hasOldPGC = NO, hasPropertyScrollNotification = NO, hasRecommendationAd = NO, hasFleaMarketing = NO, hasActivity = NO, hasCommonMenu = NO;
        // 常用菜单容器
        __block SEGMenuListModel *containerModel = nil;
        __block NSArray<SEGMenuListModel*>* data;
        
        dispatch_barrier_async(queue, ^{
            data = [[SEGMenulist2Manager sharedManager] segResponseMenuWithAction:action isSuccessed:isSuccessed result:result codeType:codeType errorMessage:errorMessage];
            [strongSelf segShowLocalDataWithAction:action settingsId:settingsId];
            
            for (SEGMenuListModel *object in data) {
                if (object.widgetType.integerValue == SEGEnumShowTypeTopLine) hasTopLine = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeHotNews) hasHotNews = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeNewPGC) hasNewPGC = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeAD) hasAD = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeFindTalk) hasNeighborTalk = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeRecommendBanner_HLB) hasRecommendationAd = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeHotPGC) hasOldPGC = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypePropertyScrollNotification||object.widgetType.integerValue ==SEGEnumShowTypePropertyScrollNotificationWithMore||object.widgetType.integerValue == SEGEnumShowTypeLuNengNotification||object.widgetType.integerValue == SEGEnumShowTypeJNNotification) hasPropertyScrollNotification = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeFleaMarketing) hasFleaMarketing = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeCommunityActivity) hasActivity = YES;
                if (object.widgetType.integerValue == SEGEnumShowTypeFourColumsSpread_common) {
                    hasCommonMenu = YES;
                    containerModel = object;
                }
            }
        });
        
        //菜单解析
        dispatch_group_async(group, queue, ^{
            [weakSelf segMenuListlayoutWithData:data];
        });
        
        //邻里头条
        //V4.7.0-需求：邻里头条实时请求
        dispatch_group_async(group, queue, ^{
            if (hasTopLine) {
                dispatch_group_enter(group);
                [strongSelf requestTopLineFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    if (isSuccessed) strongSelf.neighborData = result;
                    if (!strongSelf.neighborData || strongSelf.neighborData.count <= 0) strongSelf.neighborData = [SEGMenuListManager segGetNeighborTopLine];
                    dispatch_group_leave(group);
                }];
            }
        });
        
        //测滑推荐位
        dispatch_group_async(group, queue, ^{
            if (hasHotNews) {
                dispatch_group_enter(group);
                [strongSelf requestHotNewsWithParams:hotNewsParams Finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    if (isSuccessed) strongSelf.squareData = result;
                    if (!strongSelf.squareData || strongSelf.squareData.count <= 0) strongSelf.squareData = [SEGMenuListManager segGetHotNews];
                    dispatch_group_leave(group);
                }];
            }
        });
        
        //物业通知
        dispatch_group_async(group, queue, ^{
            if (hasPropertyScrollNotification) {
                dispatch_group_enter(group);
                [strongSelf segRequestPropertyNoticeFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    strongSelf.propertyNoticeData = result;
                    dispatch_group_leave(group);
                }];
            }
        });
        
        //PGC推荐位
        dispatch_group_async(group, queue, ^{
            if (hasNewPGC) {
                dispatch_group_enter(group);
                [strongSelf.pgcManager segRequestRecommendPGCFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    dispatch_group_leave(group);
                }];
            }
        });
        
        //广告
        dispatch_group_async(group, queue, ^{
            if (hasAD) {
                dispatch_group_enter(group);
                [strongSelf requestADWithPositionType:type finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    SEGEnumAdvertismentType adType = SEGEnumAdvertismentType_NO;
                    if (type == SEGAdvlistType_SERVER)adType = SEGEnumAdvertismentType_Find;
                    SEGAdvertisementViewModel *data = result;
                    if(data) strongSelf.advertisementData = result;
                    if (!strongSelf.advertisementData || !strongSelf.advertisementData.adSource || strongSelf.advertisementData.adSource.count <= 0) {
                        NSArray *ad = [[SEGAdvlistManager sharedManager] segGetAdvertisementWithPostion:type];
                        strongSelf.advertisementData = [strongSelf segAdvertisementWithData:ad type:type];
                    }
                    
                    dispatch_group_leave(group);
                }];
            }
        });
        
        //精品推荐
        dispatch_group_async(group, queue, ^{
            if (hasRecommendationAd) {
                dispatch_group_enter(group);
                [strongSelf requestADWithPositionType:SEGAdvlistType_Recommendation finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    SEGAdvertisementViewModel *data = result;
                    if(data) strongSelf.recommendationAdvertisementData = result;
                    dispatch_group_leave(group);
                }];
            }
        });
        
        //邻居们都在聊
        dispatch_group_async(group, queue, ^{
            if (hasNeighborTalk) {
                dispatch_group_enter(group);
                [strongSelf segFindtalkFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    if (!isSuccessed) {
                        // 需要实时刷新数据，接口失败就不展示
                        strongSelf.neighbourhoodTalkData = nil;
                        return;
                    }
                    if (isSuccessed || [SEGQueryneighborhoodmoreManager sharedManager].neighborhoodListArray.count > 0) {
                        SEGNeighbourhoodTalkViewModel *data = [SEGNeighbourhoodTalkViewModel new];
                        data.neighborhoodListArray = [SEGQueryneighborhoodmoreManager sharedManager].neighborhoodListArray;
                        strongSelf.neighbourhoodTalkData = data;
                    }
                    dispatch_group_leave(group);
                }];
            }
        });
        
        // 跳蚤市场
        dispatch_group_async(group, queue, ^{
            if (hasFleaMarketing) {
                dispatch_group_enter(group);
                [strongSelf segRequestFleaMarketingDataWithFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    if (isSuccessed) {
                    }
                    dispatch_group_leave(group);
                }];
            }
        });
        
        
        // 社区活动
        dispatch_group_async(group, queue, ^{
            if (hasActivity) {
                dispatch_group_enter(group);
                [strongSelf segRequestActivityDataWithFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    dispatch_group_leave(group);
                }];
            }
        });
        
        //老得PGC
        dispatch_group_async(group, queue, ^{
            if (hasOldPGC) {
                dispatch_group_enter(group);
                [strongSelf requestOldPGCFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    NSArray<SEGMenuQuizTypeList*> *ret = result;
                    if (isSuccessed && ret && ret.count > 0) {
                        SEGMenuSideslipViewModel *data = [[SEGMenuSideslipViewModel alloc]init];
                        
                        NSMutableArray *arrM = [NSMutableArray array];
                        
                        for (SEGMenuQuizTypeList *object in ret) {
                            [arrM addObject:[[SEGUhomeMediator sharedInstance] seg_initOldPGCViewController:@{@"quizTypeId":object.id,
                                                                                                              @"forwordVC":targetVC,
                                                                                                              @"isRecommend":object.IsRecommend
                                                                                                              }]];
                        }
                        
                        data.contentDataSource = arrM;
                        data.titleDataSource = ret;
                        strongSelf.oldPgcData = data;
                    }
                    dispatch_group_leave(group);
                }];
            }
        });
        
        // 常用菜单数据
        dispatch_group_async(group, queue, ^{
            if (hasCommonMenu) {
                dispatch_group_enter(group);
                [[SEGMenulist2Manager sharedManager] requestMenulist2WithMenuversion:@"1" menuSid:@"" appCode:kAppPlatformCode settingsId:@"" action:kActionCOMMON_MENULIST completed:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                    NSArray<SEGMenuListModel *> *serverData = [[SEGMenulist2Manager sharedManager] segResponseMenuWithAction:kActionCOMMON_MENULIST isSuccessed:isSuccessed result:result codeType:codeType errorMessage:errorMessage];
                    [strongSelf menuList_saveCommonMenuWithContainerModel:containerModel data:serverData];
                    dispatch_group_leave(group);
                }];
            }
        });
        
        //异步函数通知响应
        dispatch_group_notify(group, queue, ^{
            [strongSelf.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
                [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
                    if(objRow.widgetType.integerValue == SEGEnumShowTypeAD) {//广告
                        SEGEnumAdvertismentType adType = SEGEnumAdvertismentType_NO;
                        if (type == SEGAdvlistType_SERVER) adType = SEGEnumAdvertismentType_Find;
                    };
                }];
            }];
            // 把数据封装成SEGMenuListModel, 控制row的数量
            self.menuListDataArr = [self menuList_packagingDataToSEGMenuListModelWithAction:action PositionType:type settingsId:settingsId];
            
            [self segFilterUselessData];
            
            dispatch_async(dispatch_get_main_queue(), ^{
                finished(hasTopLine, hasAD, hasCommonMenu, self.neighborData);
            });
        });
        
    }];
}

/// 处理常用菜单数据, 保存常用菜单数据到本地
/// @param containerModel 容器
/// @param commonMenuData 常用菜单数据
/// @author Joeyoung
- (void)menuList_saveCommonMenuWithContainerModel:(SEGMenuListModel *)containerModel data:(NSArray<SEGMenuListModel *> *)commonMenuData {
    // 1). 获取常用应用
    SEGMenuListModel *commonMenuModel = [SEGMenuListCacheManager menuCache_getCommonMenuDataWithMaxCount:12 more:YES];
    NSMutableArray<SEGMenuListModel *> *newChildListData = [NSMutableArray<SEGMenuListModel *> array];
    // 2). 保存服务端最新数据
    if (commonMenuModel.childList.count == 0) { // 2_a). 不存在常用应用, 保存服务端默认常用菜单
        [commonMenuData enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if (obj.isDefaultCommonMenu.integerValue == 1) {
                [newChildListData addObject:obj];
            }
        }];
    } else {// 2_b). 存在常用应用
        [commonMenuModel.childList enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            [commonMenuData enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull serverObj, NSUInteger idx, BOOL * _Nonnull stop) {
                if (obj.settingsId.integerValue == serverObj.settingsId.integerValue) {
                    [newChildListData addObject:serverObj];
                }
            }];
        }];
    }
    // 3). 本地不存在"更多按钮", 新增
    if (![newChildListData.lastObject.action isEqualToString:kActionCOMMON_MENULIST]) {
       SEGMenuListModel *model = [SEGMenuListModel new];
       model.action = kActionCOMMON_MENULIST;
       model.iosicon = @"commonMenu_more";
       model.serviceName = @"更多应用";
       [newChildListData addObject:model];
    }
    // 4). 更新容器, 绑定常用应用数据
    commonMenuModel = containerModel;
    commonMenuModel.childList = [newChildListData copy];
    // 5). 更新本地常用应用
    [SEGMenuListCacheManager menuCache_saveCommonMenuWithData:commonMenuModel];
}

/**
 * 过滤掉菜单布局中不展示的部分
 * 遍历数据源，如果 tag = YES，删除数据源
 * @author Sam
 * @version 4.6.0
 */
- (void)segFilterUselessData {
    NSMutableArray<NSArray<SEGMenuListModel *> *> *dataSec = [NSMutableArray array];
    [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
        NSMutableArray<SEGMenuListModel *> *dataRow = [NSMutableArray array];
        [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
            if (objRow.tag == NO) [dataRow addObject:objRow];
        }];
        if (dataRow.count > 0) [dataSec addObject:[NSArray arrayWithArray:dataRow]];
    }];
    self.menuListDataArr = [NSArray arrayWithArray:dataSec];
}

/**
 * 获取服务器底部Tab菜单数据
 * @author Sam
 * @version 4.6.0
 */
-(void)segRequestMenuListForTabBarV2Finished:(SEGNetworkReponse)finished{
    [self requestMenuListWithMenuSidV2:@"0" settingsId:@"0" action:@"" finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        NSArray<SEGMenuListModel*>* data = [self segResponseMenuWithAction:@"Tab" isSuccessed:isSuccessed result:result codeType:codeType errorMessage:errorMessage];
        if (!data && data.count <= 0) {
            finished(NO,nil,codeType,errorMessage);
            return;
        }
        
        //保存菜单父子级关系，用于打红点
        [[SEGUhomeMediator sharedInstance] seg_saveMenuList:@{@"array":data,@"parentsSid":@"0"}];
        self.dataSourceTabBar = [NSArray arrayWithArray:data];
        
        finished(YES,nil,codeType,errorMessage);
    }];
}

/**
 * 获取本地菜单数据
 * @author Sam
 * @version 4.6.0
 */
-(void)segShowLocalDataWithAction:(NSString*)action settingsId:(NSString*)settingsId{
    //1.获取本地首页菜单数据
    NSArray<SEGMenuListModel*>* menuData = [self segGetMenuListDataWithLocalPath:action];
    
    if (!menuData || menuData.count <= 0)return;
    
    //保存菜单父子级关系，用于打红点
    [[SEGUhomeMediator sharedInstance] seg_saveMenuList:@{@"array":menuData,@"parentsSid":ValueToString(settingsId)}];
    [self segMenuListlayoutWithData:menuData];
}

/**
 数据模型分类排序
 
 @param data 数据模型
 */
- (void)segMenuListlayoutWithData:(NSArray<SEGMenuListModel *> *)data {
    //先返回展示菜单
    NSArray<NSArray<SEGMenuListModel *> *> *tmp = [SEGMenuListManager seg_menuListCategory:data];
    self.menuListDataArr = [NSArray arrayWithArray:tmp];
    // 去除数据模型转Layout逻辑
    //    self.menuListDataArr = [SEGMenuListManager segDataSource:tmp];
}

/**
 * 手动刷新PGC数据
 * @author Sam
 * @version 4.6.0
 */
-(void)segManualRequstPGCFinished:(void(^)(BOOL isSuccessed, NSInteger index))finished{
    [self.pgcManager segRefreshPgcDataWithPageNo:0 finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (isSuccessed) {
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                __block NSInteger index = 0;
                // 删掉现在的PGC数据 替换成新的
                NSMutableArray<NSArray<SEGMenuListModel *> *> *tempMenuListDataArr = [NSMutableArray array];
                [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull sectionModelArray, NSUInteger idx, BOOL * _Nonnull stop) {
                    NSMutableArray<SEGMenuListModel*> *tempSectionModelArray = [NSMutableArray array];
                    __block NSInteger pgcIndex = -1;
                    __block SEGMenuListModel *tempMenuListModel = nil;
                    [sectionModelArray enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull menuListModel, NSUInteger idx, BOOL * _Nonnull stop) {
                        if (menuListModel.widgetType.integerValue == SEGEnumShowTypeNewPGC) {
                            if (pgcIndex == -1) {
                                pgcIndex = idx;
                            }
                            tempMenuListModel = menuListModel;
                        } else {
                            [tempSectionModelArray addObject:menuListModel];
                        }
                    }];
                    
                    if (pgcIndex != -1) {
                        // 插入当前最新的PGC数据
                        NSMutableArray<SEGMenuListModel*> *pgcMenuListModelArray = [NSMutableArray array];
                        [self.pgcManager.pgcModelArray enumerateObjectsUsingBlock:^(SEGPgcRecommendModel * _Nonnull pgcRecommendModel, NSUInteger idx, BOOL * _Nonnull stop) {
                            SEGMenuListModel *model = [[SEGMenuListModel alloc] init];
                            model.widgetType = tempMenuListModel.widgetType;
                            model.rn = tempMenuListModel.rn;
                            model.disGroup = tempMenuListModel.disGroup;
                            model.pgcRecommendModel = pgcRecommendModel;
                            [pgcMenuListModelArray addObject:model];
                        }];
                        
                        [tempSectionModelArray insertObjects:pgcMenuListModelArray atIndex:pgcIndex];
                    }
                    [tempMenuListDataArr addObject:[tempSectionModelArray copy]];
                }];
                self.menuListDataArr = [tempMenuListDataArr copy];

                dispatch_async(dispatch_get_main_queue(), ^{
                    finished(isSuccessed,index);
                    return;
                });
            });
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            finished(NO,0);
            return;
        });
    }];
}

/// 根据PGC id请求对应实体
/// @param idArray idArray
/// @param finished finished
-(void)segManualRequstPGCWithIDArray:(NSArray *)idArray finished:(void(^)(BOOL isSuccessed, NSInteger index))finished {
    [self.pgcManager segRefreshPgcDataWithID:idArray finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (isSuccessed) {
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                __block NSInteger index = 0;
                // 删掉现在的PGC数据 替换成新的
                NSMutableArray<NSArray<SEGMenuListModel *> *> *tempMenuListDataArr = [NSMutableArray array];
                [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull sectionModelArray, NSUInteger idx, BOOL * _Nonnull stop) {
                    NSMutableArray<SEGMenuListModel*> *tempSectionModelArray = [NSMutableArray array];
                    __block NSInteger pgcIndex = -1;
                    __block SEGMenuListModel *tempMenuListModel = nil;
                    [sectionModelArray enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull menuListModel, NSUInteger idx, BOOL * _Nonnull stop) {
                        if (menuListModel.widgetType.integerValue == SEGEnumShowTypeNewPGC) {
                            if (pgcIndex == -1) {
                                pgcIndex = idx;
                            }
                            tempMenuListModel = menuListModel;
                        } else {
                            [tempSectionModelArray addObject:menuListModel];
                        }
                    }];
                    
                    if (pgcIndex != -1) {
                        // 插入当前最新的PGC数据
                        NSMutableArray<SEGMenuListModel*> *pgcMenuListModelArray = [NSMutableArray array];
                        [self.pgcManager.pgcModelArray enumerateObjectsUsingBlock:^(SEGPgcRecommendModel * _Nonnull pgcRecommendModel, NSUInteger idx, BOOL * _Nonnull stop) {
                            SEGMenuListModel *model = [[SEGMenuListModel alloc] init];
                            model.widgetType = tempMenuListModel.widgetType;
                            model.rn = tempMenuListModel.rn;
                            model.disGroup = tempMenuListModel.disGroup;
                            model.pgcRecommendModel = pgcRecommendModel;
                            [pgcMenuListModelArray addObject:model];
                        }];
                        
                        [tempSectionModelArray insertObjects:pgcMenuListModelArray atIndex:pgcIndex];
                    }
                    [tempMenuListDataArr addObject:[tempSectionModelArray copy]];
                }];
                self.menuListDataArr = [tempMenuListDataArr copy];

                dispatch_async(dispatch_get_main_queue(), ^{
                    finished(isSuccessed,index);
                    return;
                });
            });
            return;
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            finished(NO,0);
            return;
        });
    }];
}


/**
 * 请求老得PGC列表
 * @author Sam
 * @version 4.6.0
 */
-(void)requestOldPGCFinished:(SEGNetworkReponse)finished{
    
    [[SEGQuiztypelistManager sharedManager] requestQuiztypelistWithParameters:@{@"isPgcType":@"1"} finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (isSuccessed) {
            NSDictionary *data = [result valueForKey:@"data"];
            if (data && [data isKindOfClass:[NSDictionary class]]) {
                NSArray *quizTypeList = [data valueForKey:@"quizTypeList"];
                if (quizTypeList && [quizTypeList isKindOfClass:[NSArray class]]) {
                    NSMutableArray<SEGMenuQuizTypeList*> *retM = [NSMutableArray array];
                    
                    SEGMenuQuizTypeList* tmp = [[SEGMenuQuizTypeList alloc] init];
                    tmp.quizDesc = @"推荐";
                    tmp.IsRecommend = @"1";
                    tmp.id = @"-1";
                    [retM addObject:tmp];
                    
                    for (NSDictionary *object in quizTypeList) {[retM addObject:[SEGMenuQuizTypeList yy_modelWithDictionary:object]];}
                    finished(YES,retM,codeType,errorMessage);
                    return;
                }
            }
        }
        finished(NO,nil,codeType,errorMessage);
    }];
}


/**
 请求PGC列表数据
 @author Sam
 @version 4.6.0
 @param pageNo 页数
 @param pageSize 每页总数
 @param quizTypeId PGC类型
 @param isRecommend 是否是推荐位
 */
-(void)requestOldPGCListPageNo:(NSInteger)pageNo PageSize:(NSInteger)pageSize quizTypeId:(NSString*)quizTypeId isRecommend:(NSString*)isRecommend finished:(SEGNetworkReponse)finished{
    SEGProfileModel* Account = [SEGProfileManager sharedManager].profile;
    NSDictionary* params = @{
                             @"type" : @"1",
                             @"pageNo" : @(pageNo),
                             @"pageSize" : @(pageSize),
                             @"quizTypeId" : quizTypeId,
                             @"isRecommend" : isRecommend,
                             @"userId" : kAccountUserID,
                             @"provinceId" : Account.provinceId,
                             @"cityId" : Account.cityId,
                             @"regionId" : Account.regionId,
                             @"communityId" : kAccountCommunityID
                             };
    
    [[SEGPictoriallistManager sharedManager] requestPictoriallistWithParameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (!(isSuccessed && [[result allKeys] containsObject:@"data"])) {
            finished(NO,nil,codeType,errorMessage);
            return;
        }
        NSDictionary *data = [result valueForKey:@"data"];
        if (!([data isKindOfClass:[NSDictionary class]] && [[data allKeys] containsObject:@"pictorialList"] && [[data valueForKey:@"pictorialList"] isKindOfClass:[NSArray class]])) {
            //self.oldPGCDataSource = [NSArray array];
            finished(YES,nil,codeType,errorMessage);
            return;
        }
        NSArray *pictorialList = [data valueForKey:@"pictorialList"];
        
        __block NSMutableArray<SEGOldPGCListViewLayout*>* arrM = [NSMutableArray array];
        if (pageNo != 1) arrM = [NSMutableArray arrayWithArray:self.oldPGCDataSource];
        self.oldPGCFreshCount = pictorialList.count;
        for (NSDictionary *object in pictorialList) {
            
            SEGPictorialListModel *tmp = [SEGPictorialListModel yy_modelWithDictionary:object];
            tmp.createTime = [SEGUtils getShowDateWithTimer:tmp.createTime];
            
            SEGOldPGCListViewModel *model = [SEGOldPGCListViewModel new];
            model.pictorialData = tmp;
            SEGOldPGCListViewLayout *layout = [[SEGOldPGCListViewLayout alloc]initWithData:model type:tmp.pictorialStyle.integerValue];
            [arrM addObject:layout];
        }
        self.oldPGCDataSource = [NSArray arrayWithArray:arrM];
        finished(YES,nil,codeType,errorMessage);
        return;
    }];
}

/**
 * 请求菜单接口
 * @author Sam
 * @version 4.6.0 版本修改
 * @param menuSid  菜单ID
 */
-(void)requestMenuListWithMenuSidV2:(NSString*)menuSid settingsId:(NSString*)settingsId action:(NSString*)action finished:(SEGNetworkReponse)finished{
    [[SEGMenulist2Manager sharedManager] requestMenulist2WithMenuversion:@"1" menuSid:menuSid appCode:kAppPlatformCode settingsId:settingsId ? settingsId : @"" action:@"" completed:finished];
}
#pragma mark - ==============v4.5.0版本==============

#pragma mark - 请求菜单接口+布局处理的总方法

/**
 * 获取本地的业务数据进行展示
 * @author Sam
 */
-(void)segShowLocalDataWithAction:(NSString*)action settingsId:(NSString*)settingsId PositionType:(SEGAdvlistType)type finished:(SEGNetworkReponse)finished{
    //1.获取本地首页菜单数据
    NSArray<SEGMenuListModel*>* menuData = [self segGetMenuListDataWithLocalPath:action];
    [self segMenuListlayoutWithData:menuData settingsId:settingsId finished:finished];
    [self segConectionMenuDataAndBusinessDataInLocal:YES PositionType:type tencentSource:nil hotNewsParams:nil Finished:finished];
}

/**
 * 请求菜单接口
 * @author Sam
 */
-(void)segRequestMenuListWithMenuSid:(NSString*)menuSid
                              action:(NSString*)action
                          settingsId:(NSString*)settingsId
                        PositionType:(SEGAdvlistType)type
                       tencentSource:(NSArray<GDTNativeExpressAdView*> *)code
                       hotNewsParams:(NSDictionary*)hotNewsParams
                            finished:(SEGNetworkReponse)finished{
    
    [self requestMenuListWithMenuSid:menuSid settingsId:settingsId action:action finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (!isSuccessed) {
            finished(NO,nil,codeType,errorMessage);
            return;
        }
        [self segMenuListlayoutWithData:result settingsId:settingsId finished:finished];
        //新的菜单结构绑定本地数据
        [self segConectionMenuDataAndBusinessDataInLocal:YES PositionType:type tencentSource:code hotNewsParams:nil Finished:finished];
        //新的菜单结构请求&绑定网络数据
        [self segConectionMenuDataAndBusinessDataInLocal:NO PositionType:type tencentSource:code hotNewsParams:nil Finished:finished];
    }];
}

/**
 * 刷新PGC数据，并且进行和主数据源进行绑定
 * @author Sam
 */
-(void)segFreshPgcDataWithTencentSource:(NSArray<GDTNativeExpressAdView*> *) source finished:(SEGNetworkReponse)finished{
    [self.pgcManager segRefreshPgcDataWithPageNo:0 finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (isSuccessed) {
            
            __block BOOL hasPGC = NO;
            [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
                
                [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow , NSUInteger idxRow, BOOL * _Nonnull stopRow) {
                    
                    if(objRow.widgetType.integerValue == SEGEnumShowTypeNewPGC){//如果存在PGC就去布局PGC列表
                        hasPGC = YES;
//                        [objRow segInitPGCLayoutWithLayout:self.pgcManager.pgcDataLayout tencentAdSource:source type:SEGEnumSEGAutoTableViewType_NO];
                    }
                }];
            }];
            
            finished(hasPGC,result,codeType,errorMessage);
            return;
        }
        finished(NO,result,codeType,errorMessage);
        return;
    }];
}

#pragma mark - 把菜单数据和本地数据绑定在一起
-(void)segMenuListlayoutWithData:(NSArray<SEGMenuListModel *> *)data settingsId:(NSString*)settingsId finished:(SEGNetworkReponse)finished{
    if (!data || data.count <= 0)return;
    
    //保存菜单父子级关系，用于打红点
    [[SEGUhomeMediator sharedInstance] seg_saveMenuList:@{@"array":data,@"parentsSid":settingsId}];
    //先返回展示菜单
    NSArray<NSArray<SEGMenuListModel *> *> *data1 = [SEGMenuListManager seg_menuListCategory:data];
    self.menuListDataArr = [NSArray arrayWithArray:data1];
    // 去除数据模型转Layout逻辑
    //    self.menuListDataArr = [SEGMenuListManager segDataSource:data1];
    finished(YES,nil,@"",@"MenuListKey");
}

/**
 * 把菜单数据和本地数据绑定在一起
 * @author Sam
 */
-(void)segConectionMenuDataAndBusinessDataInLocal:(BOOL)local
                                     PositionType:(SEGAdvlistType)type
                                    tencentSource:(NSArray<GDTNativeExpressAdView*> *)tencentSource
                                    hotNewsParams:(NSDictionary*)hotNewsParams
                                         Finished:(SEGNetworkReponse)finished{
    
//    [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListViewLayout *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
//        [objSec enumerateObjectsUsingBlock:^(SEGMenuListViewLayout * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
//
//            if(objRow.type == SEGEnumShowTypeAD){
//                if (local) {//本地
//
//
//                    NSArray *ad = [[SEGAdvlistManager sharedManager] segGetAdvertisementWithPostion:type];
//                    if (!ad || ad.count <= 0) {
//                        //                        objRow.tag = YES;
//                    }else{
//                        SEGAdvertisementViewModel* data = [self segAdvertisementWithData:ad type:type];
//                        [objRow segInitAdLayoutWithData:data type:SEGEnumAdvertismentType_Find];
//                    }
//                    finished(YES,nil,@"",@(objRow.type).stringValue);
//                }else{//网络
//                    //如果存在广告，就去请求广告接口
//                    [self requestADWithPositionType:type finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
//                        if (isSuccessed) {
//                            SEGEnumAdvertismentType adType = SEGEnumAdvertismentType_NO;
//                            if (type == SEGAdvlistType_SERVER)adType = SEGEnumAdvertismentType_Find;
//                            [objRow segInitAdLayoutWithData:result type:adType];
//                            finished(YES,nil,codeType,@(objRow.type).stringValue);
//                        }
//                    }];
//                }
//
//            }
//
//            //如果存在PGC就去请求PGC列表
//            if(objRow.type == SEGEnumShowTypeNewPGC){
//                if (local) {//本地
//                    [self.pgcManager segPGCLayoutFromLocal];
//                    if (!self.pgcManager.pgcDataLayout) {
//                        //                        objRow.tag = YES;
//                    }else{
//                        [objRow segInitPGCLayoutWithLayout:self.pgcManager.pgcDataLayout tencentAdSource:nil type:SEGEnumSEGAutoTableViewType_NO];
//                        finished(YES,nil,@"",@(objRow.type).stringValue);
//                    }
//                    finished(YES,nil,@"",@(objRow.type).stringValue);
//                }else{//网络
//                    [self.pgcManager segFirstTimeShowPGCDataWithCodeFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
//                        if (isSuccessed) {
//                            [objRow segInitPGCLayoutWithLayout:self.pgcManager.pgcDataLayout tencentAdSource:tencentSource type:SEGEnumSEGAutoTableViewType_NO];
//                            finished(YES,nil,codeType,@(objRow.type).stringValue);
//                        }
//                    }];
//                }
//
//            }
//
//            //如果存在邻里头条，去请求邻里头条接口
//            if(objRow.type == SEGEnumShowTypeTopLine){
//                if (local) {//本地
//                    NSArray *data = [SEGMenuListManager segGetNeighborTopLine];
//                    if (!data || data.count <= 0) {
//                        //                        objRow.tag = YES;
//                    }else{
//                        [objRow segInitTopLineLayoutWithData:data type:NeighborTopRollTopType_NO];
//                    }
//                    finished(YES,nil,@"",@(objRow.type).stringValue);
//                }else{//网络
//                    [self requestTopLineFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
//                        if (isSuccessed) {
//                            [objRow segInitTopLineLayoutWithData:result type:NeighborTopRollTopType_NO];
//                        }else{
//                            objRow.tag = YES;
//                        }
//                        finished(YES,nil,codeType,@(objRow.type).stringValue);
//                    }];
//                }
//            }
//
//            //如果存在推荐广场的接口，请求推荐广场的接口
//            if(objRow.type == SEGEnumShowTypeHotNews){
//                if (local) {//本地
//                    NSArray *data = [SEGMenuListManager segGetHotNews];
//                    if (!data || data.count <= 0) {
//                        //                        objRow.tag = YES;
//                    }else{
//                        [objRow segInitHotNewsLayoutWithData:data type:SEGEnumSquareScrollViewType_NO];
//                    }
//                    finished(YES,nil,@"",@(objRow.type).stringValue);
//                }else{//网络
//                    [self requestHotNewsWithParams:hotNewsParams Finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
//                        NSMutableArray *arrM = result;
//                        if (!arrM || arrM.count <= 0) {
//                            [objRow segInitHotNewsLayoutWithData:nil type:SEGEnumSquareScrollViewType_NO];
//                            objRow.tag = YES;//没有业务数据，删除
//                        }else{
//                            [objRow segInitHotNewsLayoutWithData:arrM type:SEGEnumSquareScrollViewType_NO];
//                        }
//                        finished(YES,nil,codeType,@(objRow.type).stringValue);
//                    }];
//                }
//            }
//
//            // 邻居们都在聊
//            if(objRow.type == SEGEnumShowTypeFindTalk){
//                if (local) {//本地
//                    //                    objRow.tag = YES;//没有业务数据，删除
//                    //                    finished(YES,nil,@"",@(SEGEnumShowTypeTopLine).stringValue);
//                }else{//网络
//                    [self segFindtalkFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
//                        if (!isSuccessed || [SEGQueryneighborhoodmoreManager sharedManager].neighborhoodListArray.count <= 0) {
//                            objRow.tag = YES;
//                            [objRow segInitNeighbourhoodTalkLayoutWithData:nil type:SEGEnumNeighbourhoodTalkViewType_NO];
//                        } else {
//                            SEGNeighbourhoodTalkViewModel *data = [SEGNeighbourhoodTalkViewModel new];
//                            data.neighborhoodListArray = [SEGQueryneighborhoodmoreManager sharedManager].neighborhoodListArray;
//                            [objRow segInitNeighbourhoodTalkLayoutWithData:data type:SEGEnumNeighbourhoodTalkViewType_NO];
//                            objRow.tag = NO;
//                            finished(YES,nil,codeType,@(objRow.type).stringValue);
//                        }
//                    }];
//                }
//            }
//
//        }];
//    }];
}
#pragma mark - 把数据封装成SEGMenuListModel, 控制row的数量
/**
 把数据封装成SEGMenuListModel, 控制row的数量
 
 @return 封装好的数据
 */
- (NSArray<NSArray<SEGMenuListModel *> *> *)menuList_packagingDataToSEGMenuListModelWithAction:(NSString*)action PositionType:(SEGAdvlistType)type settingsId:(NSString*)settingsId  {
    NSMutableArray<NSArray<SEGMenuListModel *> *> *tempMenuListData = [NSMutableArray array];
    [self.menuListDataArr enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull disGroupArr, NSUInteger section, BOOL * _Nonnull stop) {
        NSMutableArray *tempSectionData = [NSMutableArray array];
        [disGroupArr enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull menuModel, NSUInteger row, BOOL * _Nonnull stop) {
            if (menuModel.widgetType.integerValue == SEGEnumShowTypeFindTalk ||
                menuModel.widgetType.integerValue == SEGEnumShowTypeNeighbour_HLB) { // 邻居们都在聊
                // 如果没有邻里都在聊的数据，则添加一个占位数据
                if (self.neighbourhoodTalkData.neighborhoodListArray.count == 0) {
                    SEGMenuListModel *model = [[SEGMenuListModel alloc] init];
                    model.widgetType = menuModel.widgetType;
                    model.rn = menuModel.rn;
                    model.disGroup = menuModel.disGroup;
                    model.neighborhoodData = nil;
                    model.serviceName = menuModel.serviceName;
                    model.disGroupWidgetType = menuModel.disGroupWidgetType;
                    model.disGroupIsShow = menuModel.disGroupIsShow;
                    model.disGroupIsMargin = menuModel.disGroupIsMargin;
                    model.disGroupName = menuModel.disGroupName;
                    model.disGroupAndroidIcon = menuModel.disGroupAndroidIcon;
                    model.disGroupIosIcon = menuModel.disGroupIosIcon;
                    model.disGroupDesc = menuModel.disGroupDesc;
                    [tempSectionData addObject:model];
                } else {
                    [self.neighbourhoodTalkData.neighborhoodListArray enumerateObjectsUsingBlock:^(SEGSharedNeihborhoodModel * _Nonnull subNeihModel, NSUInteger idx, BOOL * _Nonnull stop) {
                        SEGMenuListModel *model = [[SEGMenuListModel alloc] init];
                        model.widgetType = menuModel.widgetType;
                        model.rn = menuModel.rn;
                        model.disGroup = menuModel.disGroup;
                        model.neighborhoodData = subNeihModel;
                        model.serviceName = menuModel.serviceName;
                        model.disGroupWidgetType = menuModel.disGroupWidgetType;
                        model.disGroupIsShow = menuModel.disGroupIsShow;
                        model.disGroupIsMargin = menuModel.disGroupIsMargin;
                        model.disGroupName = menuModel.disGroupName;
                        model.disGroupAndroidIcon = menuModel.disGroupAndroidIcon;
                        model.disGroupIosIcon = menuModel.disGroupIosIcon;
                        model.disGroupDesc = menuModel.disGroupDesc;
                        [tempSectionData addObject:model];
                    }];
                }
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeTopLine) { // 邻里头条
                menuModel.neighborTopLineData = self.neighborData;
                [tempSectionData addObject:menuModel];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeHotNews) { // 侧滑推荐
                menuModel.squareData = self.squareData;
                [tempSectionData addObject:menuModel];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeTwoColumsSpread) { // 一行两列 平铺
                [SEGMenuListManager menuList_packagingRowToSEGMenuListModel:menuModel sectionArr:tempSectionData row:2];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeThreeColumsSpread) { // 一行三列 平铺
                [SEGMenuListManager menuList_packagingRowToSEGMenuListModel:menuModel sectionArr:tempSectionData row:3];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeFourColumsSpread) { // 一行四列 平铺
                [SEGMenuListManager menuList_packagingRowToSEGMenuListModel:menuModel sectionArr:tempSectionData row:4];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeFiveColumsSpread) { // 一行五列 平铺
                [SEGMenuListManager menuList_packagingRowToSEGMenuListModel:menuModel sectionArr:tempSectionData row:5];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeAD) { // 广告
                SEGEnumAdvertismentType adType = SEGEnumAdvertismentType_NO;
                if (type == SEGAdvlistType_SERVER) adType = SEGEnumAdvertismentType_Find;
                menuModel.advertisementData = self.advertisementData;
                menuModel.advertisementData.adType = adType;
                menuModel.advertisementData.communityName = kAccountCommunityName;
                [tempSectionData addObject:menuModel];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeNewPGC) {
                // 新PGC
                [self.pgcManager.pgcModelArray enumerateObjectsUsingBlock:^(SEGPgcRecommendModel * _Nonnull pgcRecommendModel, NSUInteger idx, BOOL * _Nonnull stop) {
                    SEGMenuListModel *model = [[SEGMenuListModel alloc] init];
                    model.widgetType = menuModel.widgetType;
                    model.rn = menuModel.rn;
                    model.disGroup = menuModel.disGroup;
                    model.pgcRecommendModel = pgcRecommendModel;
                    model.disGroupWidgetType = menuModel.disGroupWidgetType;
                    model.disGroupIsShow = menuModel.disGroupIsShow;
                    model.disGroupIsMargin = menuModel.disGroupIsMargin;
                    model.disGroupName = menuModel.disGroupName;
                    model.disGroupAndroidIcon = menuModel.disGroupAndroidIcon;
                    model.disGroupIosIcon = menuModel.disGroupIosIcon;
                    model.disGroupDesc = menuModel.disGroupDesc;
                    [tempSectionData addObject:model];
                }];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeMenuHeader) {
                //[[SEGMenuHeadViewLayout alloc] initWithData:menuModel.childList adData:self.advertisementData type:SEGEnumMenuHeadViewType_NO];
                menuModel.advertisementData = self.advertisementData;
                [tempSectionData addObject:menuModel];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeHotPGC) {
                //[objRow segInitOldPGCLayoutWithData:_oldPgcData type:SEGEnumMenuSideslipViewType_NO]
                menuModel.oldPGCDataSource = self.oldPgcData;
                [tempSectionData addObject:menuModel];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypePropertyScrollNotification||menuModel.widgetType.integerValue ==SEGEnumShowTypePropertyScrollNotificationWithMore||menuModel.widgetType.integerValue == SEGEnumShowTypeLuNengNotification||menuModel.widgetType.integerValue == SEGEnumShowTypeJNNotification) {
                //物业通知类型
                menuModel.propertyNoticeData = self.propertyNoticeData;
                [tempSectionData addObject:menuModel];
            } else if(menuModel.widgetType.integerValue == SEGEnumShowTypeRecommendBanner_HLB) {
                //精品推荐类型
                menuModel.advertisementData = self.recommendationAdvertisementData;
                [tempSectionData addObject:menuModel];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeFleaMarketing) {
                //跳蚤市场
                menuModel.fleaMarketData = [self.marketManager.marketList copy];
                [tempSectionData addObject:menuModel];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeFourColumsSpread_common) { // 常用菜单
                // 获取常用应用
                SEGMenuListModel *commonMenuModel = [SEGMenuListCacheManager menuCache_getCommonMenuData];
                [SEGMenuListManager menuList_packagingRowToSEGMenuListModel:commonMenuModel sectionArr:tempSectionData row:4];
            } else if (menuModel.widgetType.integerValue == SEGEnumShowTypeCommunityActivity) {
                //社区活动
                if (self.activityModels.count > 0) {
                    [self.activityModels enumerateObjectsUsingBlock:^(SEGActivityListModel * _Nonnull activityModel, NSUInteger idx, BOOL * _Nonnull stop) {
                        SEGMenuListModel *model = [[SEGMenuListModel alloc] init];
                        model.widgetType = menuModel.widgetType;
                        model.rn = menuModel.rn;
                        model.disGroup = menuModel.disGroup;
                        model.serviceName = menuModel.serviceName;
                        model.disGroupWidgetType = menuModel.disGroupWidgetType;
                        model.disGroupIsShow = menuModel.disGroupIsShow;
                        model.disGroupIsMargin = menuModel.disGroupIsMargin;
                        model.disGroupName = menuModel.disGroupName;
                        model.disGroupAndroidIcon = menuModel.disGroupAndroidIcon;
                        model.disGroupIosIcon = menuModel.disGroupIosIcon;
                        model.disGroupDesc = menuModel.disGroupDesc;
                        if (idx == self.activityModels.count - 1) {
                            activityModel.isLastActivity = YES;
                        }
                        model.activityModel = activityModel;
                        [tempSectionData addObject:model];
                    }];
                } else {
                    // 占位数据
                    [tempSectionData addObject:menuModel];
                }
            }else{
                [tempSectionData addObject:menuModel];
            }
        }];
        [tempMenuListData addObject:tempSectionData];
    }];
    return tempMenuListData;
}

+ (void)menuList_packagingRowToSEGMenuListModel:(SEGMenuListModel *)menuModel sectionArr:(NSMutableArray *)tempSectionData row:(NSUInteger)row {
    __block SEGMenuListModel *model = [[SEGMenuListModel alloc]init];
    model.widgetType = menuModel.widgetType;
    model.disGroupWidgetType = menuModel.disGroupWidgetType;
    model.disGroupIsShow = menuModel.disGroupIsShow;
    model.disGroupIsMargin = menuModel.disGroupIsMargin;
    model.disGroupName = menuModel.disGroupName;
    model.disGroupAndroidIcon = menuModel.disGroupAndroidIcon;
    model.disGroupIosIcon = menuModel.disGroupIosIcon;
    model.disGroupDesc = menuModel.disGroupDesc;
    
    __block NSMutableArray *tmp = [NSMutableArray array];
    [menuModel.childList enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objD, NSUInteger idxD, BOOL * _Nonnull stopD) {
        [tmp addObject:objD];
        model.childList = tmp ;
        if (idxD%row == (row - 1)) {
            model.childList = [tmp copy];
            //新建
            model = [[SEGMenuListModel alloc]init];
            model.widgetType = menuModel.widgetType;
            model.disGroupWidgetType = menuModel.disGroupWidgetType;
            model.disGroupIsShow = menuModel.disGroupIsShow;
            model.disGroupIsMargin = menuModel.disGroupIsMargin;
            model.disGroupName = menuModel.disGroupName;
            model.disGroupAndroidIcon = menuModel.disGroupAndroidIcon;
            model.disGroupIosIcon = menuModel.disGroupIosIcon;
            model.disGroupDesc = menuModel.disGroupDesc;
            
            tmp = [NSMutableArray array];
        }
        if (![tempSectionData containsObject:model]) {
            if (model.childList.count > 0) {
                [tempSectionData addObject:model];
            }
        }
    }];
}

#pragma mark - 菜单数据转Layout布局逻辑处理
/*
 1. 通过 disGroup 字段进行分组。
 2. 通过 widgetType 控件类型进行展示
 3.
 */
+ (NSArray<NSArray<SEGMenuListModel *> * >*)seg_menuListCategory:(NSArray<SEGMenuListModel *> *)data {
    // 把每组数据收集起来
    NSMutableArray<NSArray<SEGMenuListModel *> *> *sectionDataArr = [NSMutableArray array];
    
    NSMutableArray *disGroupArr = [NSMutableArray array];
    for (SEGMenuListModel *model in data) {
        // 这里需要判断空
        if (model.disGroup && ![disGroupArr containsObject:model.disGroup]) {
            [disGroupArr addObject:model.disGroup];
        }
    }
    /*到家汇1.7.0，4.7.0，Sam，菜单通过disGroup进行升序排序*/
    NSComparator cmptr = ^(NSString * obj1, NSString * obj2) {
        if ([obj1 integerValue] > [obj2 integerValue]) {
            return (NSComparisonResult)NSOrderedDescending;
        }
        if ([obj1 integerValue] < [obj2 integerValue]) {
            return (NSComparisonResult)NSOrderedAscending;
        }
        return (NSComparisonResult)NSOrderedSame;
    };
    NSArray *disGroupSort = [disGroupArr sortedArrayUsingComparator:cmptr];
    
    [disGroupSort enumerateObjectsUsingBlock:^(NSString * _Nonnull disGroup, NSUInteger idx, BOOL * _Nonnull stop) {
        NSMutableArray<SEGMenuListModel *> *tmp = [NSMutableArray array];// 每组的数据
        [data enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull menuModel, NSUInteger idxData, BOOL * _Nonnull stopData) {
            if ([disGroup isEqualToString:menuModel.disGroup]) {
                [tmp addObject:menuModel];
            }
        }];
        NSArray *ret = [self seg_widgetWithData:[NSArray arrayWithArray:tmp]];
        [sectionDataArr addObject:ret];
    }];
    return sectionDataArr;
}

/*
 1. 通过 disGroup 字段进行分组。
 2. 通过 widgetType 控件类型进行展示
 3.
 */
+(NSArray<SEGMenuListRowModel*>*)seg_menuListCategoryV2:(NSArray<SEGMenuListModel*>*)data{
    //把每组数据收集起来
    NSMutableArray<SEGMenuListRowModel*>* sectionData = [NSMutableArray array];
    
    NSMutableArray *disGroup = [NSMutableArray array];
    for (SEGMenuListModel *disGroupData in data) {
        if(![disGroup containsObject:disGroupData.disGroup]){
            [disGroup addObject:disGroupData.disGroup];
        }
    }
    
    /*到家汇1.7.0，4.7.0，Sam，菜单通过disGroup进行升序排序*/
    NSComparator cmptr = ^(NSString * obj1, NSString * obj2){
        if ([obj1 integerValue] > [obj2 integerValue]) {
            return (NSComparisonResult)NSOrderedDescending;
        }
        
        if ([obj1 integerValue] < [obj2 integerValue]) {
            return (NSComparisonResult)NSOrderedAscending;
        }
        return (NSComparisonResult)NSOrderedSame;
    };
    NSArray *disGroupSort = [disGroup sortedArrayUsingComparator:cmptr];
    
    [disGroupSort enumerateObjectsUsingBlock:^(NSString*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSMutableArray<SEGMenuListModel*> *tmp = [NSMutableArray array];//每组的数据
        [data enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objData, NSUInteger idxData, BOOL * _Nonnull stopData) {
            if ([obj isEqualToString:objData.disGroup]) {
                [tmp addObject:objData];
            }
        }];
        //NSArray *ret = [self seg_widgetWithData:[NSArray arrayWithArray:tmp]];
        SEGMenuListRowModel *ret = [self seg_widgetWithDataV2:[NSArray arrayWithArray:tmp]];
        [sectionData addObject:ret];
    }];
    return sectionData;
}

+ (NSArray<SEGMenuListModel *> *)seg_widgetWithData:(NSArray<SEGMenuListModel *> *)data {
    /*到家汇1.7.0，4.7.0，Sam，菜单通过rn进行升序排序*/
    NSComparator cmptr = ^(SEGMenuListModel * obj1, SEGMenuListModel * obj2) {
        if ([obj1.rn integerValue] > [obj2.rn integerValue]) {
            return (NSComparisonResult)NSOrderedDescending;
        }
        if ([obj1.rn integerValue] < [obj2.rn integerValue]) {
            return (NSComparisonResult)NSOrderedAscending;
        }
        return (NSComparisonResult)NSOrderedSame;
    };
    NSArray *dataSort = [data sortedArrayUsingComparator:cmptr];
    
    NSMutableArray<SEGMenuListModel*> *rowsData = [NSMutableArray array];
    
    NSMutableArray *widgetType = [NSMutableArray array];
    [dataSort enumerateObjectsUsingBlock:^(SEGMenuListModel *widgetTypeData, NSUInteger idx, BOOL * _Nonnull stop) {
        if(widgetTypeData.widgetType.length > 0 && ![widgetType containsObject:widgetTypeData.widgetType]) {
            [widgetType addObject:widgetTypeData.widgetType];
        }
    }];
    
    [widgetType enumerateObjectsUsingBlock:^(NSString*  _Nonnull objW, NSUInteger idxW, BOOL * _Nonnull stopW) {
        if(objW.integerValue == SEGEnumShowTypeTwoColumsSpread||
           objW.integerValue == SEGEnumShowTypeTwoColums||
           objW.integerValue == SEGEnumShowTypeFourColums||
           objW.integerValue == SEGEnumShowTypeFourColumsSpread||
           objW.integerValue == SEGEnumShowTypeThreeColums||
           objW.integerValue == SEGEnumShowTypeThreeColumsSpread||
           objW.integerValue == SEGEnumShowTypeFiveColumsSpread||
           objW.integerValue == SEGEnumShowTypeColorBlock||
           objW.integerValue == SEGEnumShowTypeMenuHeader||
           objW.integerValue == SEGEnumShowTypeColorBlock_HLB ||
           objW.integerValue == SEGEnumShowTypeCircleAndRect||
           objW.integerValue == SEGEnumShowTypeHorizontalColums ||
           objW.integerValue == SEGEnumShowTypeColorBlock_BCH) {
            
            NSMutableArray<SEGMenuListModel *> *tmp = [NSMutableArray array];
            [dataSort enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objD, NSUInteger idxD, BOOL * _Nonnull stopD) {
                if(objD.widgetType.integerValue == objW.integerValue) [tmp addObject:objD];
            }];
            
            /*到家汇1.7.0，4.7.0，Sam，菜单通过rn进行升序排序*/
            NSArray<SEGMenuListModel *> *sorArray = [tmp sortedArrayUsingComparator:cmptr];
            
            SEGMenuListModel *firstData = sorArray.firstObject;
            
            SEGMenuListModel *model = [[SEGMenuListModel alloc]init];
            model.widgetType = objW;
            model.childList = sorArray;
            
            model.disGroupWidgetType = firstData.disGroupWidgetType;
            model.disGroupIsShow = firstData.disGroupIsShow;
            model.disGroupIsMargin = firstData.disGroupIsMargin;
            model.disGroupName = firstData.disGroupName;
            model.disGroupAndroidIcon = firstData.disGroupAndroidIcon;
            model.disGroupIosIcon = firstData.disGroupIosIcon;
            model.disGroupDesc = firstData.disGroupDesc;
            
            [rowsData addObject:model];
        }else{
            [dataSort enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objD, NSUInteger idx1, BOOL * _Nonnull stop1) {
                if (objD.widgetType.integerValue == objW.integerValue){
                    if (objD.widgetType.integerValue == SEGEnumShowTypeHouseAuthentication) objD.serviceName = kAccountCommunityName;
                    [rowsData addObject:objD];
                }
            }];
        }
    }];
    
    /*到家汇1.7.0，4.7.0，Sam，菜单通过rn进行升序排序*/
    //NSArray *sorArray = [rowsData sortedArrayUsingComparator:cmptr];
    return rowsData;
}

+(SEGMenuListRowModel *)seg_widgetWithDataV2:(NSArray<SEGMenuListModel*>*)data{
    
    SEGMenuListRowModel *rowData = [SEGMenuListRowModel new];
    
    NSMutableArray<NSString*> *widgetType = [NSMutableArray array];//获取Row组中所有的控件类型
    for (SEGMenuListModel *widgetTypeData in data) {
        if(widgetTypeData.widgetType.length > 0 && ![widgetType containsObject:widgetTypeData.widgetType])[widgetType addObject:widgetTypeData.widgetType];
    }
    
    //每个disgroup中如果存在控件类型=SEGEnumShowTypeNewPGC，那么这个disgroup中只能存在SEGEnumShowTypeNewPGC类型的数据并且只能存在一条。
    if ([widgetType containsObject:@(SEGEnumShowTypeNewPGC).stringValue]) {
        [data enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objD, NSUInteger idxD, BOOL * _Nonnull stopD) {
            if(objD.widgetType.integerValue == SEGEnumShowTypeNewPGC) {
                rowData.type = SEGEnumShowTypeNewPGC;
                rowData.bussinessMenu = objD;
            }
            *stopD = YES;
        }];
        return rowData;
    }
    
    //遍历disgroup中的数据，通过控件类型进行分类，把多组数据存放到到childList中
    NSMutableArray<SEGMenuListModel *> *rows = [NSMutableArray array];
    [widgetType enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSInteger type = obj.integerValue;
        BOOL isMutColumns = type == SEGEnumShowTypeTwoColumsSpread|| type == SEGEnumShowTypeTwoColums||
        type == SEGEnumShowTypeFourColums|| type == SEGEnumShowTypeFourColumsSpread||
        type == SEGEnumShowTypeThreeColums|| type == SEGEnumShowTypeThreeColumsSpread || type == SEGEnumShowTypeFiveColumsSpread||
        type == SEGEnumShowTypeHorizontalColums;
        
        if (isMutColumns) {
            NSMutableArray *tmp = [NSMutableArray array];
            
            [data enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objD, NSUInteger idxD, BOOL * _Nonnull stopD) {
                if(objD.widgetType.integerValue == type) [tmp addObject:objD];
            }];
            
            SEGMenuListModel *firstData = tmp.firstObject;
            
            SEGMenuListModel *model = [[SEGMenuListModel alloc]init];
            
            model.disGroupWidgetType = firstData.disGroupWidgetType;
            model.disGroupIsShow = firstData.disGroupIsShow;
            model.disGroupIsMargin = firstData.disGroupIsMargin;
            model.disGroupName = firstData.disGroupName;
            model.disGroupAndroidIcon = firstData.disGroupAndroidIcon;
            model.disGroupIosIcon = firstData.disGroupIosIcon;
            model.disGroupDesc = firstData.disGroupDesc;
            
            model.widgetType = obj;
            model.childList = tmp;
            [rows addObject:model];
        }else{
            [data enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objD, NSUInteger idx1, BOOL * _Nonnull stop1) {
                if (objD.widgetType.integerValue == obj.integerValue){
                    //添加特殊逻辑：如果action = kActionHOUSE_CERTIFICATION，进行展示小区名、特殊跳转。
                    if (objD.widgetType.integerValue == SEGEnumShowTypeNormal &&
                        [objD.action isEqualToString:kActionHOUSE_CERTIFICATION]) {
                        objD.serviceName = kAccountCommunityName;
                    }
                    [rows addObject:objD];
                }
            }];
        }
    }];
    
    rowData.normalMenu = rows;
    return rowData;
    
    
    NSMutableArray<SEGMenuListModel*> *rowsData = [NSMutableArray array];
    
    //NSMutableArray *widgetType = [NSMutableArray array];
    for (SEGMenuListModel *widgetTypeData in data) {
        if(widgetTypeData.widgetType.length > 0 && ![widgetType containsObject:widgetTypeData.widgetType])[widgetType addObject:widgetTypeData.widgetType];
    }
    
    [widgetType enumerateObjectsUsingBlock:^(NSString*  _Nonnull objW, NSUInteger idxW, BOOL * _Nonnull stopW) {
        
        if(objW.integerValue == SEGEnumShowTypeTwoColumsSpread||
           objW.integerValue == SEGEnumShowTypeTwoColums||
           objW.integerValue == SEGEnumShowTypeFourColums||
           objW.integerValue == SEGEnumShowTypeFourColumsSpread||
           objW.integerValue == SEGEnumShowTypeThreeColums||
           objW.integerValue == SEGEnumShowTypeThreeColumsSpread||
           objW.integerValue == SEGEnumShowTypeFiveColumsSpread||
           objW.integerValue == SEGEnumShowTypeCircleAndRect||
           objW.integerValue == SEGEnumShowTypeHorizontalColums){
            
            NSMutableArray *tmp = [NSMutableArray array];
            [data enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objD, NSUInteger idxD, BOOL * _Nonnull stopD) {
                if(objD.widgetType.integerValue == objW.integerValue) [tmp addObject:objD];
            }];
            
            SEGMenuListModel *model = [[SEGMenuListModel alloc]init];
            
            SEGMenuListModel *firstData = tmp.firstObject;
            model.disGroupWidgetType = firstData.disGroupWidgetType;
            model.disGroupIsShow = firstData.disGroupIsShow;
            model.disGroupIsMargin = firstData.disGroupIsMargin;
            model.disGroupName = firstData.disGroupName;
            model.disGroupAndroidIcon = firstData.disGroupAndroidIcon;
            model.disGroupIosIcon = firstData.disGroupIosIcon;
            model.disGroupDesc = firstData.disGroupDesc;
            
            model.widgetType = objW;
            model.childList = tmp;
            [rowsData addObject:model];
            
        }else{
            [data enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objD, NSUInteger idx1, BOOL * _Nonnull stop1) {
                if (objD.widgetType.integerValue == objW.integerValue){
                    //添加特殊逻辑：如果action = kActionHOUSE_CERTIFICATION，进行展示小区名、特殊跳转。
                    if (objD.widgetType.integerValue == SEGEnumShowTypeNormal &&
                        [objD.action isEqualToString:kActionHOUSE_CERTIFICATION]) {
                        objD.serviceName = kAccountCommunityName;
                    }
                    [rowsData addObject:objD];
                }
            }];
        }
    }];
    return rowsData;
}

///**
// * 模型转layout
// * @author Sam
// */
//+(NSArray<NSArray<SEGMenuListViewLayout*>*>*)segDataSource:(NSArray<NSArray<SEGMenuListModel*>*>*)sourceData{
//    NSMutableArray<NSMutableArray<SEGMenuListViewLayout*>*>* ret = [NSMutableArray array];
//
//    [sourceData enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
//        NSMutableArray<SEGMenuListViewLayout*> *tmp = [NSMutableArray array];
//        [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
//            NSInteger t = objRow.widgetType.integerValue;
//            SEGMenuListViewLayout *layout = [[SEGMenuListViewLayout alloc]initWithData:objRow type:t];
//            [tmp addObject:layout];
//        }];
//        [ret addObject:tmp];
//    }];
//    return ret;
//}

///**
// * 模型转layout
// * @author Sam
// */
//+(NSArray<NSArray<SEGMenuListViewLayout*>*>*)segDataSourceV2:(NSArray<SEGMenuListRowModel*>*)sourceData{
//    NSMutableArray<NSMutableArray<SEGMenuListViewLayout*>*>* ret = [NSMutableArray array];
//    //    [sourceData enumerateObjectsUsingBlock:^(NSArray<SEGMenuListModel *> * _Nonnull objSec, NSUInteger idxSec, BOOL * _Nonnull stopSec) {
//    //        NSMutableArray<SEGMenuListViewLayout*> *tmp = [NSMutableArray array];
//    //        [objSec enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull objRow, NSUInteger idxRow, BOOL * _Nonnull stopRow) {
//    //            NSInteger t = objRow.widgetType.integerValue;
//    //            SEGMenuListViewLayout *layout = [[SEGMenuListViewLayout alloc]initWithData:objRow type:t];
//    //            [tmp addObject:layout];
//    //        }];
//    //        [ret addObject:tmp];
//    //    }];
//
//    /*
//     模型转layout
//     1.普通类型：直接添加数组
//     */
//    [sourceData enumerateObjectsUsingBlock:^(SEGMenuListRowModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//        if(obj.type != SEGEnumShowTypeNewPGC){
//            [obj.normalMenu enumerateObjectsUsingBlock:^(SEGMenuListModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//                SEGMenuListViewLayout *layout = [[SEGMenuListViewLayout alloc]initWithData:obj type:obj.widgetType.integerValue];
//            }];
//        }else{
//            SEGMenuListViewLayout *layout = [[SEGMenuListViewLayout alloc]initWithData:obj.bussinessMenu type:obj.bussinessMenu.type.integerValue];
//        }
//    }];
//    return ret;
//}

#pragma mark - 基本的网络请求
/**
 * 请求广告
 * @author Sam
 */
-(void)requestADWithPositionType:(SEGAdvlistType)type finished:(SEGNetworkReponse)finished{
    
    [[SEGAdvlistManager sharedManager] segRequestAdvlistWithPositionType:type completed:^(BOOL isSuccessed, id  _Nonnull result, NSString * _Nonnull codeType, NSString * _Nonnull errorMessage) {
        if (isSuccessed) {
            SEGAdvertisementViewModel *data = [self segAdvertisementWithData:result type:type];
            finished(isSuccessed,data,codeType,errorMessage);
            return;
        }
        finished(NO,nil,codeType,errorMessage);
    }];
}

-(SEGAdvertisementViewModel*)segAdvertisementWithData:(NSArray<SEGAdvertismentModel*>*)dt type:(SEGAdvlistType)type{
    SEGAdvertisementViewModel *data = [[SEGAdvertisementViewModel alloc]init];
    //SEGCommunityLocationViewModel *com = [[SEGCommunityLocationViewModel alloc]init];
    //com.communityName = kAccountCommunityName;
    data.adSource = dt;
    //data.communityModel = com;
    data.communityName = kAccountCommunityName;
    if (type == SEGAdvlistType_SERVER){
        data.locationShowType = SEGEnumCommunityLocationViewType_Location;
    }
    return data;
}


// 请求邻里头条
- (void)requestTopLineFinished:(SEGNetworkReponse)finished {
    NSString *cityID = [SEGProfileManager sharedManager].profile.cityId;
    NSDictionary *params = @{@"cityId":cityID};
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/",kCMS_api,@"/bbs/queryNeighborhood.json",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        dispatch_queue_t queue = dispatch_queue_create("com.uhome.topline", DISPATCH_QUEUE_CONCURRENT);
        dispatch_async(queue, ^{
            
            NSArray *locaData = [SEGMenuListManager segGetNeighborTopLine];
            if (!isSuccessed) {
                if (locaData && locaData.count > 0) {
                    finished(YES,locaData,codeType,errorMessage);
                    return;
                }
                finished(NO,result,codeType,errorMessage);
                return;
            }
            
            NSDictionary* dicData = [result valueForKey:@"data"];
            if ((!dicData) || (![dicData isKindOfClass:[NSDictionary class]])) {
                if (locaData && locaData.count > 0) {
                    finished(YES,locaData,codeType,errorMessage);
                    return;
                }
                finished(NO,result,codeType,errorMessage);
                return;
            }
            
            NSArray* list = [dicData valueForKey:@"neighborhood"];
            
            if (!list || ![list isKindOfClass:[NSArray class]]) {
                if (locaData && locaData.count > 0) {
                    finished(YES,locaData,codeType,errorMessage);
                    return;
                }
                finished(NO,result,codeType,errorMessage);
                return;
            }
            
            NSMutableArray<SEGNeighborRollViewModel*>* arrM = [NSMutableArray arrayWithCapacity:list.count];
            for (NSDictionary* dic in list) {
                SEGNeighborRollViewModel* _model = [SEGNeighborRollViewModel yy_modelWithDictionary:dic];
                [arrM addObject:_model];
            }
            [SEGMenuListManager segSaveNeighborTopLineWithData:[NSArray arrayWithArray:arrM]];
            
            if ( arrM && arrM.count > 0) {
                finished(YES,arrM,codeType,errorMessage);
            }else{
                if (locaData && locaData.count > 0) {
                    finished(YES,locaData,codeType,errorMessage);
                    return;
                }else{
                    finished(NO,result,codeType,errorMessage);
                    return;
                }
            }
            return;
            
        });
    }];
}
/**
 * 请求物业通知
 * @author Sam
 */
-(void)segRequestPropertyNoticeFinished:(SEGNetworkReponse)finished {
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/",@"bms-api",@"/info/queryAppInfoPage?pageNo=1&pageLimit=5&platform=",kAppPlatformCode,nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:nil finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (!isSuccessed) {
            finished(NO,nil,codeType,errorMessage);
            return;
        }
        NSArray *data = result[@"data"][@"infoList"];
        if (!data || ![data isKindOfClass:[NSArray class]]) {
            finished(NO,nil,codeType,errorMessage);
            return;
        }
        NSMutableArray<SEGPropertyNoticeVerticalRollSingleViewModel*> *arrM = [NSMutableArray array];
        for (NSDictionary *object in data) {
            if (arrM.count >= 5) break;
            SEGPropertyNoticeVerticalRollSingleViewModel *data = [SEGPropertyNoticeVerticalRollSingleViewModel yy_modelWithDictionary:object];
            [arrM addObject:data];
        }
        finished(YES,arrM,codeType,errorMessage);
    }];
}

/**
 *  请求推荐侧滑
 * @author Sam
 */
-(void)requestHotNewsWithParams:(NSDictionary*)params Finished:(SEGNetworkReponse)finished{
    //侧滑推荐位
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/cms-api/api/v2/queryRecommend",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        dispatch_queue_t queue = dispatch_queue_create("com.uhome.hotnews", DISPATCH_QUEUE_CONCURRENT);
        dispatch_async(queue, ^{
            
            if (!isSuccessed) {
                finished(NO,nil,codeType,errorMessage);
                return;
            }
            
            NSDictionary* dicData = [result valueForKey:@"data"];
            if ((!dicData) || (![dicData isKindOfClass:[NSDictionary class]])) {
                finished(NO,nil,codeType,errorMessage);
                return;
            }
            
            NSArray* list = [dicData valueForKey:@"recommend"];
            
            if (!list || ![list isKindOfClass:[NSArray class]]) {
                finished(NO,nil,codeType,errorMessage);
                return;
            }
            
            NSMutableArray<SEGSquareViewModel*>* arrM = [NSMutableArray arrayWithCapacity:list.count];
            for (NSDictionary* dic in list) {
                SEGSquareViewModel *model = [SEGSquareViewModel yy_modelWithDictionary:dic];
                model.type = SEGEnumSquareViewType_NO;
                [arrM addObject:model];
            }
            
            [SEGMenuListManager segSaveHotNewsWithData:[NSArray arrayWithArray:arrM]];
            
            finished(YES,arrM,codeType,errorMessage);
            
        });
    }];
}

/**
 * 请求邻居们都在聊
 * @author Sam
 */
-(void)segFindtalkFinished:(SEGNetworkReponse)finished{
    NSString *cityID = [SEGProfileManager sharedManager].profile.cityId;
    NSString *pageLimit = @"5";
    [[SEGQueryneighborhoodmoreManager sharedManager] requestNeighborhoodWithScopeId:@"3"
                                                                              objId:nil
                                                                             cityId:cityID
                                                                            objType:nil
                                                                             pageNo:@"1"
                                                                          pageLimit:pageLimit
                                                                        communityId:kAccountCommunityID
                                                                           moduleId:@"1"
                                                                           finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
                                                                               finished(isSuccessed,nil,codeType,errorMessage);
                                                                           }];
}

/**
 请求菜单跳蚤市场数据

 @param finished finished
 */
-(void)segRequestFleaMarketingDataWithFinished:(SEGNetworkReponse)finished {
    // scopeId 传参3，代表查询全平台集市数据
    WeakSelf;
    [self.marketManager requestMarketListByTypeID:@"" scopeId:@"3" pageNo:@"1" pageLimit:4 cityID:nil Finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed, weakSelf.marketManager.marketList,codeType,errorMessage);
    }];
}

/**
 请求菜单活动数据
 
 @param finished finished
 */
-(void)segRequestActivityDataWithFinished:(SEGNetworkReponse)finished {
    WeakSelf;
    [self.activityManager requestMenuActivityListWithFinished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        weakSelf.activityModels = nil;
        if (isSuccessed) {
            weakSelf.activityModels = result;
        }
        finished(isSuccessed, result, codeType, errorMessage);
    }];
}

/**
 * 请求菜单接口
 * @author Sam
 * @param menuSid  菜单ID
 */
-(void)requestMenuListWithMenuSid:(NSString*)menuSid settingsId:(NSString*)settingsId action:(NSString*)action finished:(SEGNetworkReponse)finished{
    NSDictionary *params = @{@"appCode":kAppPlatformCode,@"menuSid":menuSid,@"menuVersion":@"1",@"settingsId":settingsId ? settingsId : @""};
    
    [[SEGMenulist2Manager sharedManager] requestMenulist2WithMenuversion:@"1" menuSid:menuSid appCode:kAppPlatformCode settingsId:settingsId ? settingsId : @"" action:@"" completed:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        NSArray<SEGMenuListModel*> *ret = [NSArray array];
        
        //请求失败，获取本地数据
        if (!isSuccessed) {
            ret = [self segGetMenuListDataWithLocalPath:action];
            
            if (ret && ret.count > 0) {//没有网络数据获取本地缓存
                finished(YES,ret,codeType,errorMessage);
                return;
            }
            
            finished(NO,nil,codeType,errorMessage);
            return;
        }
        
        //字典转模型
        NSMutableArray<SEGMenuListModel*> *arrM = [NSMutableArray array];
        NSArray *data = [result valueForKey:@"data"];
        
        if (data && [data isKindOfClass:[NSArray class]]) {
 
            for (NSDictionary *object in data) {
                if (object && [object isKindOfClass:[NSDictionary class]]) {
                    SEGMenuListModel *data = [SEGMenuListModel yy_modelWithDictionary:object];
                    [arrM addObject:data];
                }
            }
                
         }
        
        //网络请求成功，请求到数据，保存到本地并且返回
        if(arrM.count > 0){
            ret = [NSArray arrayWithArray:arrM];
            [self segSaveMenuListData:ret localPath:action];
            finished(YES,ret,codeType,errorMessage);
            return;
        }
        
        //网络请求成功，请求到空数据,获取本地缓存数据
        ret = [self segGetMenuListDataWithLocalPath:action];
        
        if (ret && ret.count > 0) {//没有网络数据获取本地缓存
            finished(YES,ret,codeType,errorMessage);
            return;
        }
        
        //服务器和本地都没有数据返回失败
        finished(NO,nil,codeType,errorMessage);
        return;
    }];
}




/**
 * 菜单数据请求回调
 * @author Sam
 * @version 4.6.0
 */
-(NSArray<SEGMenuListModel*>*)segResponseMenuWithAction:(NSString*)action isSuccessed:(BOOL)isSuccessed result:(id)result codeType:(NSString*)codeType errorMessage:(NSString*)errorMessage{
    NSArray<SEGMenuListModel*> *ret = [NSArray array];
    
    //请求失败，获取本地数据
    if (!isSuccessed) {
        ret = [self segGetMenuListDataWithLocalPath:action];
        return ret;
    }
    
    //请求成功
    NSMutableArray<SEGMenuListModel*> *arrM = [NSMutableArray array];
    
    NSArray *data = [[result allKeys]containsObject:@"data"] ? [result valueForKey:@"data"] : nil;
    if (data && [data isKindOfClass:[NSArray class]]) {
        for (NSDictionary *object in data) {
            if (object && [object isKindOfClass:[NSDictionary class]]) {
                SEGMenuListModel *data = [SEGMenuListModel yy_modelWithDictionary:object];
                
                if ([action isEqualToString:@"Tab"]) { //如果是底部Tab数据，只添加action位Tab的数据
                    if ([data.action rangeOfString:@"TAB_"].location != NSNotFound) {
                        [arrM addObject:data];
                    }
                }else{
                    [arrM addObject:data];
                }
            }
        }
    }
    
    //网络请求成功，请求到数据，保存到本地并且返回
    if(arrM.count > 0){
        ret = [NSArray arrayWithArray:arrM];
        [self segSaveMenuListData:ret localPath:action];
        return ret;
    }
    
    // !!!:  Wendy，2019.3.20, 服务器获取到空数据就显示空的，不再读取本地 4.9.2版本修改
    //    //网络请求成功，请求到空数据,获取本地缓存数据
    //    ret = [self segGetMenuListDataWithLocalPath:action];
    return ret;
}

#pragma mark - 菜单缓存操作
/**
 * 保存菜单数据
 * @author Sam
 */
-(void)segSaveMenuListData:(NSArray<SEGMenuListModel*>*)data localPath:(NSString*)action{
    if (!data || data.count <= 0) return;
    [NSKeyedArchiver archiveRootObject:data toFile:[self segpgcMenuPath:action]];
}

/**
 * 获取菜单数据
 * @author Sam
 */
-(NSArray<SEGMenuListModel*>*)segGetMenuListDataWithLocalPath:(NSString*)action{
    NSArray<SEGMenuListModel*>* ret = [NSKeyedUnarchiver unarchiveObjectWithFile:[self segpgcMenuPath:action]];
    if ([action isEqualToString:@"Tab"]) {
        /*到家汇1.7.0，4.7.0，Sam，菜单通过rn进行升序排序*/
        NSComparator cmptr = ^(SEGMenuListModel * obj1, SEGMenuListModel * obj2){
            if ([obj1.rn integerValue] > [obj2.rn integerValue]) {
                return (NSComparisonResult)NSOrderedDescending;
            }
            
            if ([obj1.rn integerValue] < [obj2.rn integerValue]) {
                return (NSComparisonResult)NSOrderedAscending;
            }
            return (NSComparisonResult)NSOrderedSame;
        };

        return [ret sortedArrayUsingComparator:cmptr];
    }
    return ret;
}

-(NSString*)segpgcMenuPath:(NSString*)action{
    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
    return [filePath stringByAppendingPathComponent:[NSString stringWithFormat:@"menu%@%@.data",action,kAccountUserID]];
}

/**
 * 本地菜单路径
 * @author Sam
 */
-(NSString*)segpgcLocalPath:(NSString*)action{
    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
    return [filePath stringByAppendingPathComponent:[NSString stringWithFormat:@"menu%@%@Archiver.data",action,kAccountUserID]];
    
}

#pragma mark - 邻里头条缓存操作

/**
 * 保存邻里头条到本地路径
 * @author Sam
 */
+(BOOL)segSaveNeighborTopLineWithData:(NSArray<SEGNeighborRollViewModel*>*)data{
    if (!data || data.count <= 0) return NO;
    return [NSKeyedArchiver archiveRootObject:data toFile:[self segNeighborTopLineLocalPath]];
}

/**
 * 获取邻里头条
 * @author Sam
 */
+(NSArray<SEGNeighborRollViewModel*>*)segGetNeighborTopLine{
    return [NSKeyedUnarchiver unarchiveObjectWithFile:[self segNeighborTopLineLocalPath]];
}

/**
 * 本地邻里头条路径
 * @author Sam
 */
+(NSString*)segNeighborTopLineLocalPath{
    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
    return [filePath stringByAppendingPathComponent:[NSString stringWithFormat:@"NeighborTopLineArchiver%@.data",kAccountUserID]];
    
}

#pragma mark - 侧滑位缓存操作
/**
 * 保存邻里头条到本地路径
 * @author Sam
 */
+(BOOL)segSaveHotNewsWithData:(NSArray<SEGSquareViewModel*>*)data{
    if (!data || data.count <= 0) return NO;
    return [NSKeyedArchiver archiveRootObject:data toFile:[self segHotNewsLocalPath]];
}

/**
 * 获取邻里头条
 * @author Sam
 */
+(NSArray<SEGSquareViewModel*>*)segGetHotNews{
    return [NSKeyedUnarchiver unarchiveObjectWithFile:[self segHotNewsLocalPath]];
}

/**
 * 本地邻里头条路径
 * @author Sam
 */
+(NSString*)segHotNewsLocalPath{
    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
    return [filePath stringByAppendingPathComponent:[NSString stringWithFormat:@"HotNewsArchiver%@.data",kAccountUserID]];
    
}

#pragma mark - Getter
-(NSArray<SEGMenuListModel *> *)dataSourceTabBar{
    if (!_dataSourceTabBar) {
        NSArray<SEGMenuListModel*>* tmp = [self segGetMenuListDataWithLocalPath:@"Tab"];
        _dataSourceTabBar = tmp ? tmp : [NSArray array];
    }
    return _dataSourceTabBar;
}
- (NSArray<NSArray<SEGMenuListModel *> *> *)menuListDataArr {
    if (!_menuListDataArr) _menuListDataArr = [NSArray array];
    return _menuListDataArr;
}
-(SEGPgcManager *)pgcManager{
    if (!_pgcManager) {
        _pgcManager = [SEGPgcManager new];
    }
    return _pgcManager;
}
-(NSArray<SEGOldPGCListViewLayout *> *)oldPGCDataSource{
    if (!_oldPGCDataSource) {
        _oldPGCDataSource = [NSArray array];
    }
    return _oldPGCDataSource;
}

- (SEGCommunitySocialManager *)marketManager {
    if (!_marketManager) {
        _marketManager = [[SEGCommunitySocialManager alloc] init];
    }
    return _marketManager;
}

- (SEGActivityListManager *)activityManager {
    if (!_activityManager) {
        _activityManager = [[SEGActivityListManager alloc] init];
    }
    return _activityManager;
}

@end

